x<-c("m","f","m","m","f","f","f","m","f","f")
y<-c(12,34,23,44,67,54,32,43,54,26)
tapply(y,x, mean)
z<-c(1,2,3,4,5,6,7,8,9,10)
r<-c(1.83,1.68,1.88,1.78,1.64,1.69,1.72,1.75,1.72,1.69)
data.frame(x,y,z,r)

library(openxlsx)
A=read.table("C:/本科生教学/大三/R/data for class3/ADdata1.txt")
B=read.csv("C:/本科生教学/大三/R/data for class3/ADdata2.csv")
C=read.xlsx("C:/本科生教学/大三/R/data for class3/ADdata3.xlsx")
D=read.table("C:/本科生教学/大三/R/data for class3/ADdata4.txt")
data.frame(A)
data.frame(B)
data.frame(C)
data.frame(D)
A1=cbind(A,rownames(A))
names(A1)[17]="ID"
D1=cbind(D,rownames(D))
names(D1)[17]="ID"
names(B)[1]="ID"
names(C)[1]="ID"
E=merge(A1,B)
F=merge(C,D1)
G=merge(E,F)
write.table(G,file = "ADdate实践3-2.xlsx",sep="\t",row.names = TRUE,col.names = TRUE,quote = TRUE)
write.table(G,file = "ADdate实践3-2.txt",sep="\t",row.names = TRUE,col.names = TRUE,quote = TRUE)
write.csv(G,file = "ADdate实践3-2.csv")